    <!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width =device-width, initial-scale=1, maximum-scale=1" />
    <title></title>
    <meta charset="utf-8" />
    <link href="/plugins/layui/css/layui.css" rel="stylesheet" />
    <link rel="stylesheet" href="/plugins/build/css/app.css" media="all">
    <style type="text/css">
        .xtree_contianer {
            overflow: auto;
            margin-bottom: 10px;
            padding: 10px 0 25px 5px;
        }
    </style>
</head>
<body>
    <form class="layui-form">
        <div id="xtree" class="xtree_contianer"></div>
        <div class="layui-form-item custom_layer_bottom_btn">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
            </div>
        </div>
    </form>
</body>
</html>
<script src="/plugins/layui/layui.js"></script>
<script src="/plugins/layui/layui-xtree.js"></script>
<script src="/plugins/common.js"></script>
<script type="text/javascript">
    var editUrl = SERVER_URL+"/sysMenu/editRoleMenuList";
    var treeUrl = SERVER_URL+"/sysMenu/xtreeList";

    layui.use(['form', 'jquery'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var xtree = new layuiXtree({
            elem: 'xtree'
            , form: form
            , data: treeUrl+"?roleId="+urlParam("id")
        });

        //新增or修改
        form.on('submit(save)', function(data){
            var checkList = xtree.GetChecked();
            var menuIds = "";
            for (var i = 0; i < checkList.length; i++) {
                menuIds += checkList[i].value + ",";
                var parentNode = xtree.GetParent(checkList[i].value);
                if (parentNode != null && menuIds.indexOf(parentNode.value) == -1) {
                    menuIds += parentNode.value + ",";
                }
            }
            menuIds = menuIds.substring(0,menuIds.length-1);
            $.ajax({
                type: 'POST',
                url: editUrl,
                data: {roleId: urlParam("id"), menuIds: menuIds},
                success: function (result) {
                    if(result.code == 20000){
                        parent.reload();
                    }else{
                        layer.msg(result.msg, {time: 1500});
                    }
                }
            });
            return false;
        });
    });

    //地址栏参数
    function urlParam(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)	return unescape(r[2]);
        return null;
    }
</script>